package com.ycfmedical.bed.bean;

import com.ycfmedical.bed.model.BaseModel;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Egoist on 2017/1/19.
 */

public class EntertainItem extends BaseModel implements Parcelable
{
    
    /**
     * 艺术家
     */
    public String artist;
    
    /**
     * 名称
     */
    public String name;
    
    /**
     * id
     */
    public long id;
    
    /**
     * 地址
     */
    public String path;
    
    /**
     * 时间长度
     */
    public int duration;
    
    /**
     * 项目大小
     */
    public long size;

    /**
     * 专辑
     */
    public String album;
    
    public EntertainItem()
    {
        
    }
    
    // 1.必须按成员变量声明的顺序封装数据，不然会出现获取数据出错
    // 2.序列化对象
    @Override
    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeString(artist);
        dest.writeString(name);
        dest.writeLong(id);
        dest.writeString(path);
        dest.writeInt(duration);
        dest.writeLong(size);
        dest.writeString(album);
    }
    
    // 必须按成员变量声明的顺序读取数据，不然会出现获取数据出错
    public EntertainItem(Parcel in)
    {
        artist = in.readString();
        name = in.readString();
        id = in.readLong();
        path = in.readString();
        duration = in.readInt();
        size = in.readLong();
        album = in.readString();
    }
    
    @Override
    public int describeContents()
    {
        return 0;
    }
    
    // 1.必须实现Parcelable.Creator接口,否则在获取EntertainItem数据的时候，会报错，如下：
    // android.os.BadParcelableException:
    // Parcelable protocol requires a Parcelable.Creator object called CREATOR on class com.um.demo.Person
    // 2.这个接口实现了从Percel容器读取EntertainItem数据，并返回EntertainItem对象给逻辑层使用
    // 3.实现Parcelable.Creator接口对象名必须为CREATOR，不如同样会报错上面所提到的错；
    // 4.在读取Parcel容器里的数据事，必须按成员变量声明的顺序读取数据，不然会出现获取数据出错
    // 5.反序列化对象
    public static final Creator<EntertainItem> CREATOR = new Creator<EntertainItem>()
    {
        @Override
        public EntertainItem createFromParcel(Parcel in)
        {
            return new EntertainItem(in);
        }
        
        @Override
        public EntertainItem[] newArray(int size)
        {
            return new EntertainItem[size];
        }
    };
    
    public String getArtist()
    {
        return artist;
    }
    
    public void setArtist(String artist)
    {
        this.artist = artist;
    }
    
    public String getName()
    {
        return name;
    }
    
    public void setName(String name)
    {
        this.name = name;
    }
    
    public String getPath()
    {
        return path;
    }
    
    public void setPath(String path)
    {
        this.path = path;
    }
    
    public int getDuration()
    {
        return duration;
    }
    
    public void setDuration(int duration)
    {
        this.duration = duration;
    }
    
    public long getSize()
    {
        return size;
    }
    
    public void setSize(long size)
    {
        this.size = size;
    }
    
    public long getId()
    {
        return id;
    }
    
    public void setId(long id)
    {
        this.id = id;
    }
    
    public String getAlbum()
    {
        return album;
    }
    
    public void setAlbum(String album)
    {
        this.album = album;
    }
    
}
